﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace VTESCore
{
	[Serializable]
	public class VTESDeck : IEnumerable<VTESCard>
	{
		private List<CryptCard> m_CryptCards;
		private List<LibraryCard> m_LibraryCards;

		public List<CryptCard> CryptCards
		{
			get { return m_CryptCards; }
			set { m_CryptCards = value; }
		}

		public List<LibraryCard> LibraryCards
		{
			get { return m_LibraryCards; }
			set { m_LibraryCards = value; }
		}

		public VTESDeck() {}

		public VTESDeck( List<CryptCard> crypt_cards, List<LibraryCard> library_cards )
		{
			m_CryptCards = crypt_cards;
			m_LibraryCards = library_cards;
		}

		public VTESCard Find(string name)
		{
			foreach(CryptCard crypt_card in CryptCards)
			{
				if(crypt_card.Name == name)
				{
					return crypt_card;
				}
			}
			foreach(LibraryCard library_card in LibraryCards)
			{
				if(library_card.Name == name)
				{
					return library_card;
				}
			}
			return null;
		}

		#region IEnumerable<VTESCard> Members

		public IEnumerator<VTESCard> GetEnumerator()
		{
			List<VTESCard> allcards = new List<VTESCard>();
			foreach(VTESCard card in m_CryptCards)
			{
				allcards.Add( card );
			}
			foreach (VTESCard card in m_LibraryCards)
			{
				allcards.Add( card );
			}
			foreach(VTESCard card in allcards)
			{
				yield return card;
			}
		}

		#endregion

		#region IEnumerable Members

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		#endregion
	}
}
